import './assets/main.css'

import { createApp } from 'vue'
import { createPinia } from 'pinia'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'

import App from './App.vue'
import router from './router'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import i18n from './utils/lang/index'
import './assets/iconfont.css'


const app = createApp(App)
app.config.globalProperties.getToken=() => localStorage.getItem("LOGIN_STATUS_TOKEN");
app.config.globalProperties.isLogined=()=>{
    const token=getToken();
    if(token===null){
        router.push("/login");
        return false;
    }else{
        return true;
    }
}
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
}
app.use(i18n)
app.use(createPinia())
app.use(router)
app.use(ElementPlus)
app.mount('#app')

window.apiUrl = 'https://api.zehaotarpaulin.cn/api';
window.getToken = () => localStorage.getItem("LOGIN_STATUS_TOKEN");
window.isLogined=()=>{
    const token=getToken();
    if(token===null){
        router.push("/login");
        return false;
    }else{
        return true;
    }
}